package com.maben.s9001.controller;

import com.maben.s9001.domain.User;
import com.maben.s9001.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户控制类
 */
@RestController
@RequestMapping("user")
public class UserController {
    @Resource
    private UserService userService;

    @GetMapping("queryUserList")
    public List<User> queryUserList() throws Exception {
        return userService.queryUserList();
    }

    @PostMapping("saveUser")
    public void saveUser(String username,String nickName)throws Exception{
        final User user = new User();
        user.setUsername(username);
        user.setNickName(nickName);
        userService.saveUser(user);
    }
}
